package com.liusiqi.framework.beans.factory.support;

import com.liusiqi.framework.beans.BeanDefinition;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: sql
 * @date: 2024/2/22
 * @Description:注册表实现类
 * @version: 1.0
 */
public class SimpleBeanDefinitionRegistry implements BeanDefinitionRegistry{

    private Map<String, BeanDefinition> map = new HashMap<>();

    @Override
    public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) {
        map.put(beanName, beanDefinition);
    }

    @Override
    public void removeBeanDefinition(String beanName) {
        map.remove(beanName);
    }

    @Override
    public BeanDefinition getBeanDefinition(String beanName) {
        return map.get(beanName);
    }

    @Override
    public boolean containsBeanDefinition(String beanName) {
        return map.containsKey(beanName);
    }

    @Override
    public String[] getBeanDefinitionNames() {
        return map.keySet().toArray(new String[0]);
    }

    @Override
    public int getBeanDefinitionCount() {
        return map.size();
    }
}
